from django.urls import path
from . import views, views_apiview, views_genericapiview, views_mixin, views_mixinchild, views_modelViewset
# 导入路由类  DefaultRouter比SimpleRouter多了根路径的路由匹配
from rest_framework.routers import SimpleRouter,DefaultRouter

# 初始化路由类
router = DefaultRouter()
# 注册生成路由  basename 路由命名
router.register('heros', views_modelViewset.HerosView, basename='heros')
# 获取路由后的结果
print(router.urls)

urlpatterns = [
    # path('heros',views.HerosView.as_view()),
    # path('heros/<int:pk>',views.HeroView.as_view()),

    # path('heros',views_apiview.HerosView.as_view()),
    # path('heros/<int:pk>',views_apiview.HeroView.as_view()),

    # path('heros', views_genericapiview.HerosView.as_view()),
    # path('heros/<int:pk>', views_genericapiview.HeroView.as_view()),

    # path('heros', views_mixin.HerosView.as_view()),
    # path('heros/<int:pk>', views_mixin.HeroView.as_view()),

    # path('heros', views_mixinchild.HerosView.as_view()),

    # 视图集的路由匹配  {'get':'list'} key对应请求方式  value是视图方法
    #     path('heros', views_modelViewset.HerosView.as_view({'get':'list','post':'create'})),
    #     path('heros/<int:pk>', views_modelViewset.HerosView.as_view({'get':'retrieve','put':'update','delete':'destroy'})),
    # path('heros/last_data', views_modelViewset.HerosView.as_view({'get':'last_data'}))

]
# 将生成的路由添加到原有的路由列表中
urlpatterns += router.urls
